-#
  Copyright 2008 Garth Williams

  This file is part of CommandPost.

  CommandPost is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  CommandPost is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with CommandPost.  If not, see <http://www.gnu.org/licenses/>.


%h1 Users

%table
  %tr
    %th Display Name
    %th Login
    %th Email
  - for user in @users
    %tr
      -if current_user.has_role?('Administrators')
        %td= link_to h(user.name), user
        %td= link_to h(user.login), user
      -else
        %td= h user.name
        %td= h user.login
      %td= link_to user.email, "mailto:#{user.email}"
    -if current_user.has_role?('Administrators')
      %tr
        %td{:colspan => '3'}
          - for role in @roles
            %span.small{:id => "role_#{role.id}"}
              = check_box_tag "role_#{role.id}_check", 'checked', user.roles.include?(role)
              = h role.name
              = observe_field "role_#{role.id}_check", :url => { :action => 'update', :user_id => user.id, :role_id => role.id }, :frequency => 0.5, :complete => visual_effect(:highlight, "role_#{role.id}")
          